<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>connect</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="compilestr.html" title="compilestr" />
    <link rel="next" href="control.html" title="control" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">connect</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="compilestr.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="control.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="connect"></a>
      <div class="titlepage"></div>
      <a id="Indexconnect" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">connect</span>
        </h2>
        <p>connect — 
      Connects a source outlet to a sink inlet.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp95283072"></a>
        <h2>Description</h2>
        <p>
      The connect opcode, valid only in the orchestra header, sends the signals
      from the indicated outlet in all instances of the indicated source
      instrument to the indicated inlet in all instances of the indicated sink
      instrument. Each inlet instance receives the sum of the signals in all 
      outlet instances. Thus multiple instances of an outlet may fan in to one 
      instance of an inlet, or one instance of an outlet may fan out to 
      multiple instances of an inlet. 
    </p>
        <p>
      When Csound creates a new instance of an instrument template, new instances
      of its connections also are created.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp95434384"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>connect </strong></span>Tsource1, Soutlet1, Tsink1, Sinlet1</pre>
      </div>
      <div class="refsect1">
        <a id="idp95436160"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>Tsource1</em></span> -- String name of the source instrument definition.       
    </p>
        <p>
      <span class="emphasis"><em>Soutlet1</em></span> -- String name of the source outlet in the source instrument.       
    </p>
        <p>
      <span class="emphasis"><em>Tsink1</em></span> -- String name of the sink instrument definition.       
    </p>
        <p>
      <span class="emphasis"><em>Sinlet1</em></span> -- String name of the sink inlet in the sink instrument.       
    </p>
      </div>
      <div class="refsect1">
        <a id="idp95440000"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the connect opcode. It uses the file <a class="ulink" href="examples/connect.csd" target="_top"><em class="citetitle">connect.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp95441648"></a>
          <p class="title">
            <strong>Example 133. Example of the connect opcode.</strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac     <span class="comment">;;;RT audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if RT audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o connect.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="op">/</span><span class="op">*</span> Written by Michael Gogins <span class="op">*</span><span class="op">/</span>
<span class="comment">; Initialize the global variables.</span>
<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2

<span class="comment">; Connect up the instruments to create a signal flow graph.</span>

<span class="opc">connect</span> "SimpleSine",   "leftout",     "Reverberator",     	"leftin"
<span class="opc">connect</span> "SimpleSine",   "rightout",    "Reverberator",     	"rightin"

<span class="opc">connect</span> "Moogy",        "leftout",     "Reverberator",     	"leftin"
<span class="opc">connect</span> "Moogy",        "rightout",    "Reverberator",     	"rightin"

<span class="opc">connect</span> "Reverberator", "leftout",     "Compressor",       	"leftin"
<span class="opc">connect</span> "Reverberator", "rightout",    "Compressor",       	"rightin"

<span class="opc">connect</span> "Compressor",   "leftout",     "Soundfile",       	"leftin"
<span class="opc">connect</span> "Compressor",   "rightout",    "Soundfile",       	"rightin"

<span class="comment">; Turn on the "effect" units in the signal flow graph.</span>

<span class="opc">alwayson</span> "Reverberator", 0.91, 12000
<span class="opc">alwayson</span> "Compressor"
<span class="opc">alwayson</span> "Soundfile"

<span class="oblock">instr</span> SimpleSine
  ihz <span class="op">=</span> <span class="opc">cpsmidinn</span>(p4)
  iamplitude <span class="op">=</span> <span class="opc">ampdb</span>(p5)
  <span class="opc">print</span> ihz, iamplitude
  <span class="comment">; Use ftgenonce instead of ftgen, ftgentmp, or f statement.</span>
  isine <span class="opc">ftgenonce</span> 0, 0, 4096, 10, 1
  a1 <span class="opc">oscili</span> iamplitude, ihz, isine
  aenv <span class="opc">madsr</span> 0.05, 0.1, 0.5, 0.2
  asignal <span class="op">=</span> a1 <span class="op">*</span> aenv
  <span class="comment">; Stereo audio outlet to be routed in the orchestra header.</span>
  <span class="opc">outleta</span> "leftout", asignal <span class="op">*</span> 0.25
  <span class="opc">outleta</span> "rightout", asignal <span class="op">*</span> 0.75
<span class="oblock">endin</span>

<span class="oblock">instr</span> Moogy
  ihz <span class="op">=</span> <span class="opc">cpsmidinn</span>(p4)
  iamplitude <span class="op">=</span> <span class="opc">ampdb</span>(p5)
  <span class="comment">; Use ftgenonce instead of ftgen, ftgentmp, or f statement.</span>
  isine <span class="opc">ftgenonce</span> 0, 0, 4096, 10, 1
  asignal <span class="opc">vco</span> iamplitude, ihz, 1, 0.5, isine
  kfco <span class="opc">line</span> 200, p3, 2000
  krez <span class="opc">init</span> 0.9
  asignal <span class="opc">moogvcf</span> asignal, kfco, krez, 100000
  <span class="comment">; Stereo audio outlet to be routed in the orchestra header.</span>
  <span class="opc">outleta</span> "leftout", asignal <span class="op">*</span> 0.75
  <span class="opc">outleta</span> "rightout", asignal <span class="op">*</span> 0.25
<span class="oblock">endin</span>

<span class="oblock">instr</span> Reverberator
  <span class="comment">; Stereo input.</span>
  aleftin <span class="opc">inleta</span> "leftin"
  arightin <span class="opc">inleta</span> "rightin"
  idelay <span class="op">=</span> p4
  icutoff <span class="op">=</span> p5
  aleftout, arightout <span class="opc">reverbsc</span> aleftin, arightin, idelay, icutoff
  <span class="comment">; Stereo output.</span>
  <span class="opc">outleta</span> "leftout", aleftout
  <span class="opc">outleta</span> "rightout", arightout 
<span class="oblock">endin</span>

<span class="oblock">instr</span> Compressor
  <span class="comment">; Stereo input.</span>
  aleftin <span class="opc">inleta</span> "leftin"
  arightin <span class="opc">inleta</span> "rightin"
  kthreshold <span class="op">=</span> 25000
  icomp1 <span class="op">=</span> 0.5
  icomp2 <span class="op">=</span> 0.763
  irtime <span class="op">=</span> 0.1
  iftime <span class="op">=</span> 0.1
  aleftout <span class="opc">dam</span> aleftin, kthreshold, icomp1, icomp2, irtime, iftime
  arightout <span class="opc">dam</span> arightin, kthreshold, icomp1, icomp2, irtime, iftime
  <span class="comment">; Stereo output.</span>
  <span class="opc">outleta</span> "leftout", aleftout 
  <span class="opc">outleta</span> "rightout", arightout 
<span class="oblock">endin</span>

<span class="oblock">instr</span> Soundfile
  <span class="comment">; Stereo input.</span>
  aleftin <span class="opc">inleta</span> "leftin"
  arightin <span class="opc">inleta</span> "rightin"
  <span class="opc">outs</span> aleftin, arightin
<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="comment">; Not necessary to activate "effects" or create f-tables in the score!</span>
<span class="comment">; Overlapping notes to create new instances of instruments.</span>
<span class="stamnt">i</span> "S<span class="stamnt">i</span>mpleS<span class="stamnt">i</span>ne" 1 5 60 85
<span class="stamnt">i</span> "S<span class="stamnt">i</span>mpleS<span class="stamnt">i</span>ne" 2 5 64 80
<span class="stamnt">i</span> "Moogy" 3 5 67 75
<span class="stamnt">i</span> "Moogy" 4 5 71 70
<span class="comment">;6 extra seconds after the performance</span>
<span class="stamnt">e</span> 12
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp95443168"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="outleta.html" title="outleta"><em class="citetitle">outleta</em></a>
      <a class="link" href="outletk.html" title="outletk"><em class="citetitle">outletk</em></a>
      <a class="link" href="outletf.html" title="outletf"><em class="citetitle">outletf</em></a>
      <a class="link" href="inleta.html" title="inleta"><em class="citetitle">inleta</em></a>
      <a class="link" href="inletk.html" title="inletk"><em class="citetitle">inletk</em></a>
      <a class="link" href="inletf.html" title="inletf"><em class="citetitle">inletf</em></a>
      <a class="link" href="alwayson.html" title="alwayson"><em class="citetitle">alwayson</em></a>
      <a class="link" href="ftgenonce.html" title="ftgenonce"><em class="citetitle">ftgenonce</em></a>
    </p>
        <p> More information on this opcode: <a class="ulink" href="http://www.csoundjournal.com/issue13/signalFlowGraphOpcodes.html" target="_top"><em class="citetitle">http://www.csoundjournal.com/issue13/signalFlowGraphOpcodes.html</em></a>  , written by Michael Gogins </p>
      </div>
      <div class="refsect1">
        <a id="idp95451632"></a>
        <h2>Credits</h2>
        <p>By: Michael Gogins 2009</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="compilestr.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="control.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">compilestr </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> control</td>
        </tr>
      </table>
    </div>
  </body>
</html>
